home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / boxes / percent / percent.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-03-22  |  3.9 KB  |  117 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   1  'Fixed Single
  5.    ClientHeight    =   105
  6.    ClientLeft      =   4080
  7.    ClientTop       =   4650
  8.    ClientWidth     =   5385
  9.    ClipControls    =   0   'False
  10.    Enabled         =   0   'False
  11.    Height          =   510
  12.    Left            =   4020
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   105
  17.    ScaleWidth      =   5385
  18.    Top             =   4305
  19.    Width           =   5505
  20.    Begin Label Label2 
  21.       Alignment       =   2  'Center
  22.       AutoSize        =   -1  'True
  23.       BackColor       =   &H000000FF&
  24.       BackStyle       =   0  'Transparent
  25.       Caption         =   "10%"
  26.       Height          =   195
  27.       Left            =   2040
  28.       TabIndex        =   1
  29.       Top             =   0
  30.       Width           =   375
  31.    End
  32.    Begin Label Label1 
  33.       Alignment       =   2  'Center
  34.       BackColor       =   &H000000FF&
  35.       Height          =   375
  36.       Left            =   0
  37.       TabIndex        =   0
  38.       Top             =   0
  39.       Width           =   1695
  40.    End
  41. DefInt A-Z
  42. Option Explicit
  43. Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal nIndex%)
  44. Declare Function SetWindowWord% Lib "User" (ByVal hWnd%, ByVal nIndex%, ByVal wNewWord%)
  45. Declare Function GetWindowLong& Lib "User" (ByVal hWnd%, ByVal nIndex%)
  46. Declare Function SetWindowLong& Lib "User" (ByVal hWnd%, ByVal nIndex%, ByVal dwNewLong&)
  47. Const GWW_ID = (-12)
  48. Const GWL_STYLE = (-16)
  49. Const WS_DLGFRAME = &H400000
  50. Const WS_SYSMENU = &H80000
  51. Const WS_MINIMIZEBOX = &H20000
  52. Const WS_MAXIMIZEBOX = &H10000
  53. Sub Form_Load ()
  54.     Dim r
  55.     titlebar form1, False
  56.     label1.Width = 0
  57.     r = DoEvents()
  58.     form_resize
  59. End Sub
  60. Sub form_resize ()
  61.     form1.Height = 300
  62.     label1.Height = form1.Height
  63.     Label2.Left = form1.Width / 2.25
  64.     Label2.Top = (label1.Height / 2) - (Label2.Height / 2)
  65. End Sub
  66. Sub titlebar (frm As Form, ShowTitle)
  67.    Static Oldhmenu, SavedStyle&
  68.    Dim NewStyle&, t&
  69.    If ShowTitle Then
  70.       'get the current style attributes
  71.       NewStyle& = GetWindowLong&(frm.hWnd, GWL_STYLE)
  72.       
  73.       'set only the attributes that were removed earlier
  74.       NewStyle& = NewStyle& Or SavedStyle&
  75.       
  76.       're-establish the menu
  77.       If Oldhmenu <> 0 Then
  78.      t& = SetWindowWord%(frm.hWnd, GWW_ID, Oldhmenu)
  79.       End If
  80.       
  81.       'set the new style
  82.       t& = SetWindowLong&(frm.hWnd, GWL_STYLE, NewStyle&)
  83.       
  84.       'force VB to update the form
  85.       frm.Left = frm.Left
  86.       frm.Refresh
  87.    Else
  88.       'get the current style attributes
  89.       NewStyle& = GetWindowLong&(frm.hWnd, GWL_STYLE)
  90.       'determine whether the form has a dialog frame, a ControlBox,
  91.       'a minimize button, or a maximize button and save this info.
  92.       'for later use
  93.       SavedStyle& = 0
  94.       SavedStyle& = SavedStyle& Or (NewStyle& And WS_DLGFRAME)
  95.       SavedStyle& = SavedStyle& Or (NewStyle& And WS_SYSMENU)
  96.       SavedStyle& = SavedStyle& Or (NewStyle& And WS_MINIMIZEBOX)
  97.       SavedStyle& = SavedStyle& Or (NewStyle& And WS_MAXIMIZEBOX)
  98.       'remove the attributes for a dialog frame, a ControlBox, a minimize
  99.       'button and a maximize button
  100.       NewStyle& = NewStyle& And Not WS_DLGFRAME
  101.       NewStyle& = NewStyle& And Not WS_SYSMENU
  102.       NewStyle& = NewStyle& And Not WS_MINIMIZEBOX
  103.       NewStyle& = NewStyle& And Not WS_MAXIMIZEBOX
  104.       'is there a menu associated with this form?
  105.       Oldhmenu = GetWindowWord%(frm.hWnd, GWW_ID)
  106.       If Oldhmenu <> 0 Then
  107.      'yes-zero it the menu handle
  108.      t& = SetWindowWord%(frm.hWnd, GWW_ID, 0)
  109.       End If
  110.       'set the new style
  111.       t& = SetWindowLong&(frm.hWnd, GWL_STYLE, NewStyle&)
  112.       'force VB to update the form and get rid of the title bar
  113.       frm.Left = frm.Left
  114.       frm.Refresh
  115.    End If
  116. End Sub
  117.